package logic

import (
	"context"
	"zhihu/zhihurpc/zhihurpcclient"

	"zhihu/api/internal/svc"
	"zhihu/api/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

type UserProblemLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewUserProblemLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UserProblemLogic {
	return &UserProblemLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *UserProblemLogic) UserProblem(req *types.UserProblemRequest) (resp *types.Response, err error) {
	// todo: add your logic here and delete this line
	userProblem, err := l.svcCtx.ZhiHuRpc.UserProblem(
		l.ctx, &zhihurpcclient.UserProblemRequest{UserId: req.UserId})
	if err != nil {
		return &types.Response{
			Message: err.Error(),
			Data:    nil,
			Code:    500,
		}, nil
	}

	return &types.Response{
		Message: "用户问题记录展示成功",
		Data:    userProblem,
		Code:    200,
	}, nil
}
